package com.sscaipiao.android.activity.Football;

import java.util.ArrayList;
import java.util.HashMap;

import com.sscaipiao.android.R;
import com.sscaipiao.android.activity.KaijiangActivity;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

public class FootballHisActivity extends Activity{
	ListView mFootballListView;
	FootballAdapter mFootballDataAdapter;
	private TextView textview_kuai3;
	
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.football_his);
		
		Button kuai3_his_button_back = (Button)findViewById(R.id.kuai3_his_button_back);
		kuai3_his_button_back.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent intent = new Intent();
				intent.setClass(FootballHisActivity.this, KaijiangActivity.class);
				startActivity(intent);	
			}
		});
		
		 textview_kuai3 =(TextView)findViewById(R.id.textview_kuai3);
		 
		 textview_kuai3.setText("竞彩足球");
		 
		 mFootballListView = (ListView)findViewById(R.id.kuai3_his_listView);
		 mFootballDataAdapter = new FootballAdapter();
			ArrayList<HashMap<String,String>> list = new ArrayList<HashMap<String,String>>();
			HashMap<String,String> map;
			for (int i = 3; i < 6; i++) {
				map= new HashMap<String,String>();
				map.put("riqi", "2013-08-0"+i+"星期"+i);

				list.add(map);
			}
			mFootballDataAdapter.setData(list);
			mFootballListView.setAdapter(mFootballDataAdapter);
		
		
		
		
	}
	class FootballAdapter extends BaseAdapter {
		private static final int id = 0;
		ArrayList<HashMap<String,String>> mItemList;
		FootballAdapter() {
			// data
		}
		
		public void setData(ArrayList<HashMap<String, String>> data) {
			mItemList = data;
		}

		@Override
		public int getCount() {
			// TODO Auto-generated method stub
			return mItemList.size();
		}

		@Override
		public Object getItem(int position) {
			// TODO Auto-generated method stub
			return mItemList.get(position);
		}

		@Override
		public long getItemId(int position) {
			return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {

			Holder holder ;
			if (convertView == null) {
				convertView = View.inflate(FootballHisActivity.this, R.layout.football_his_item, null);
				holder = new Holder(); 
				holder.riqi = (TextView)convertView.findViewById(R.id.football_his_text5);

				ImageButton btnShowDetail = (ImageButton) convertView.findViewById(R.id.football_his_show_detail);
				final LinearLayout layoutDetail = (LinearLayout) convertView.findViewById(R.id.football_his_detail);
				btnShowDetail.setOnClickListener(new View.OnClickListener() {
					
					@Override
					public void onClick(View v) {
						if (layoutDetail.getVisibility() == View.GONE) {
							layoutDetail.setVisibility(View.VISIBLE);
						} else {
							layoutDetail.setVisibility(View.GONE);
						}
					}
				});
				
				convertView.setTag(holder);
			}
			else {
				holder = (Holder)convertView.getTag();
//				convertView.findViewById(id) 
//					mItemList.get(0);
	
			}
			HashMap<String, String> item = mItemList.get(position);
			holder.riqi.setText(item.get("riqi"));



//			//设置标题
//			convertView.findViewById(id).setTitle();
//			// 设置第几期
			return convertView;
		}
		class Holder {
			TextView riqi;


			
		}
		
	}
}